<?php 
        // create curl resource 
        $ch = curl_init(); 

        // set url 
        //curl_setopt($ch, CURLOPT_URL, "http://espnfc.com/scores?date=20130526&league=all&cc=5901&xhr=1"); 
		curl_setopt($ch, CURLOPT_URL, "http://espnfc.com/scores?date=20130602&league=all&cc=5901&xhr=1"); 
        //return the transfer as a string 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        // $output contains the output string 
        $output = curl_exec($ch); 
		
		// close curl resource to free up system resources 
        curl_close($ch); 

		$startstring = "<div class=\"group-set\">";
		
		$endstring = "</td></tr></table></div>";
		
		$start = strpos($output, $startstring);
		
		$length = strrpos($output, $endstring) - $start + strlen($endstring);
		
		$output = substr($output, $start, $length);
		
			
		$output = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><root>" . $output . "</root>";
		
		//$output = str_replace("&", "&amp;", $output);
		
		$output = str_replace("&raquo;", " ", $output);
		
		$output = str_replace("&nbsp;", " ", $output);
		
		$output = str_replace("&", "&amp;", $output);
		

		
		$xmlDoc = new DOMDocument();
		$xmlDoc->loadXML($output);
		
		
		$xpath = new DOMXpath($xmlDoc);
		
		$leagues = $xpath->query("//div[@class='mod-header']/h2/a");
		//echo "found " . $leagues->length;
		foreach ($leagues as $league) {
			echo "<div>$league->nodeValue</div>";
		}
		//$elements = $xpath->query("//div[@class='group-set']");
		//echo "found " . $elements->length;
		//foreach ($elements as $element) {
			//echo "<br>...";
			//$mod_header = $element->childNodes[0];
			//$h2 = $mod_header->childNodes[0];
			//$league = $h2->childNodes[0].nodeValue;
			//$league = $mod_header->getElementsByTagName("a")[0].childNodes[0].nodeValue;
			//echo $league;
		//}
		//if (!is_null($elements)) {
			//echo "found " . $elements->length;
			//foreach ($elements as $element) {
				//echo "<br/>[". $element->nodeName. "]";
				
				//$nodes = $element->childNodes;
				//foreach ($nodes as $node) {
					//echo $node->nodeValue. "\n";
				//}
		//	}
	//	} else {
		//	echo "No elements found";
		//}
		//echo $output;
?>